﻿namespace EqualitySample
{
    public class Point
    {
        public double X { get; set; }
        public double Y { get; set; }
        public override bool Equals(object obj)
        {
            //System.Diagnostics.Trace.TraceInformation("Entered Point.Equals. Instance {0}, parameter obj {1}.", this, obj);
            if (obj == null)
            {
                return false;
            }
            else if (!(obj is Point))
            {
                return false;
            }
            else
            {
                var p = (Point)obj;
                return X == p.X && Y == p.Y;
            }
        }
        public override int GetHashCode()
        {
            //System.Diagnostics.Trace.TraceInformation("Entered Point.GetHashCode. Instance {0}", this);
            return (17 * 23 + X.GetHashCode()) * 23 + Y.GetHashCode();
        }
        public override string ToString()
        {
            return $"[{X}, {Y}]";
        }
    }
}
